# 背景
import pygame

class Bg:
    def __init__(self, screen, screen_rect):
        self.screen = screen
        self.screen_rect = screen_rect

        self.image1 = pygame.image.load('images/bg.jpg')
        self.image1 = pygame.transform.scale(self.image1, (screen_rect.width, screen_rect.height))
        self.moveY = 0
    

    def update(self):
        self.moveY += 1
        self.display()
    
    def display(self):
        if self.moveY > self.screen_rect.height:
            self.moveY = 0
        self.screen.blit(self.image1, (0, self.moveY), self.screen_rect)
        self.screen.blit(self.image1, (0, self.moveY - self.screen_rect.height), self.screen_rect)